﻿@using Cinema_Ticketing_System.Models;
@using Cinema_Ticketing_System.Models.User;
@{
    ViewBag.Title = "Personal_Center";
    Layout = "~/Views/Shared/CinemaLayoutPage.cshtml";
}

@section styles{
    <style>
        #main{
            margin-top:10px;

        }
        td{
            width:100px;
            color:red;
        }
        .bgcolor {
            background-color: orange;
            color: white;
        }
        #div1 div:first-child {
            background-color:orange;
            color:white;
        }
        #div1 div:nth-child(2) {
            background-color: orange;
        }
        #div1 div{
            margin-top:5px;
            text-align:center;
            cursor:pointer;
        }

    </style>
}


    <div class="col-lg-12" id="main">
        <div class="col-lg-3" id="div1">
            <div>个人中心</div>
            <div>我的订单</div>
            <div>查看个人资料</div>
        </div>
        <div class="col-lg-9">
            <div style="display:block" id="box1">
                <table>
                    <thead>
                        <tr>
                            <td>订单号</td>
                            <td>电影院</td>
                            <td>座位号</td>
                            <td>电影名称</td>
                            <td>播放时间</td>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in ViewBag.listGetUSerIdentMessage as List<UserIdentMessage>)
                            {
                                <tr>
                                    <td>@item.detaillid</td>
                                    <td>@item.ciname</td>
                                    <td>@item.seet</td>
                                    <td>@item.filmname</td>
                                    <td>@item.time</td>
                                </tr>
                            }
                    </tbody>
                </table>
            </div>
            <div style="display:none" id="box2">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label for="userphone" class="col-sm-2 control-label">电话号码：</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="userphone"  value="@(((user_table)Session["currentUser"]).userphone)">
                            @Html.ValidationMessage("userphone")
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">昵称：</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="username" value="@(((user_table)Session["currentUser"]).username)">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="pwd" class="col-sm-2 control-label">密码：</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control" id="userpassword">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="newpwd" class="col-sm-2 control-label">请输入新密码：</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control" id="newpwd">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="aginnewpwd" class="col-sm-2 control-label">再次输入新密码：</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control" id="aginnewpwd">

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="button" class="btn btn-default" id="btnchange">确认修改</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

@section scripts
{
    <script>

        $(function() {

            $("#div1 div:nth-child(2)").click(function (e) {
                $(e.target).css({ "background-color": "orange" }).next().css({ "background-color": "white" });
                $("#box1").css({ "display": "block" });
                $("#box2").css({ "display": "none" });
            })

            $("#div1 div:last-child").click(function (x) {
                $(x.target).css({ "background-color": "orange" }).prev().css({ "background-color": "white" });
                $("#box2").css({ "display": "block" });
                $("#box1").css({ "display": "none" });
            })

            
            $("#btnchange").click(function () {

                var usermsg = {
                    userphone: $("#userphone").val(),
                    userpassword: $("#userpassword").val(),
                    username: $("#username").val(),
                    newpwd: $("#newpwd").val(),
                    aginnewpwd: $("#aginnewpwd").val(),
                    
                }
                console.log(usermsg);
                $.ajax({
                    url: "/User/Personal_Center",
                    type: "POST",
                    data: usermsg,
                    success: function (data) {
                        if (data == "修改成功")
                            alert(data);
                    },
                    error: function (data) {
                        alert("erroer ");
                    },
                })
            })
        })

    </script>

}